<!DOCTYPE html>

<html>
<head>
  <script src="../../resources/run-after-layout-and-paint.js"></script>
  <style type="text/css" media="screen">
    iframe {
        border: 10px solid black;
        padding: 5px;
        margin: 20px;
        height: 150px;
        width: 300px;
    }
    
    .collapsed {
      width: 0;
    }
    
    .overlay {
      position: absolute;
      width: 50px;
      height: 50px;
      top: 5px;
      left: 5px;
      background-color: rgba(0, 0, 0, 0.2);
    }
    
  </style>
  <script type="text/javascript" charset="utf-8">
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    function doTest()
    {
        var hadLayers = false;
        if (window.testRunner) {
            var layers = internals.layerTreeAsText(document);
            hadLayers = layers != "";
        }

        runAfterLayoutAndPaint(function() {
            document.getElementById('iframe').className = 'collapsed';

            if (window.testRunner) {
                var haveLayers = internals.layerTreeAsText(document) != "";
                var result;
                if (hadLayers && haveLayers)
                  result = "PASS: Had layers before and after";
                else
                  result = "FAIL: Layers should have stayed. hadLayers = " + hadLayers + ", haveLayers = " + haveLayers;
                document.getElementById('result').innerHTML = result;
                testRunner.notifyDone();
            }
        });
    }

    window.addEventListener('load', doTest, false);
  </script>
</head>
<body>

    <!-- The parent document may into compositing mode by the iframe. -->
    <iframe id="iframe" src="resources/composited-subframe.html"></iframe>
    
    <div class="overlay">
    </div>

    <div id="result">Test only works in DRT</div>
</body>
</html>
